package org.axed.user.client.util;

import java.lang.System;
import java.util.Vector;
import java.util.Stack;

/**
 * This class is a programmers tool, to be able to store some
 * profile information when running in a live webbrowser. 
 *
 * Each function or part entered, call enter() with a description.
 * And do not forget to call leave() on every path this function 
 * or path my exit.
 */
public class Profiler {
	public static Vector times = new Vector();
	static Stack stack = new Stack();
	static long begin = 0;

	public static void enter(String routine) {
		ProfileEntry e = new ProfileEntry(routine, stack.size(), System.currentTimeMillis(), 0);
		times.add(e);
		stack.push(e);
	}

	public static void leave() {
		long end = System.currentTimeMillis();
		ProfileEntry e = (ProfileEntry) stack.pop();
		e.end = end;
	}
}
